from sqlalchemy import Column, String, create_engine, BIGINT, Integer
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base


class ConnectionHelper:

    # @staticmethod
    # def __init__(self):
    #     print("in init")
    #     return



    @staticmethod
    def GetConnectionURL():
        return 'mysql+pymysql://ctbu:Ctbu_10310@jtzy.fromtech.net/vegtable?charset=utf8'

    @staticmethod
    def GetSession():
        DB_CONNECT_STRING = ConnectionHelper.GetConnectionURL()

        engine = create_engine(DB_CONNECT_STRING, echo=True)

        # 初始化数据库连接:
        # engine = create_engine('mysql+mysqlconnector://root:root@localhost:3306/ctbu')
        # 创建DBSession类型:
        DBSession = sessionmaker(bind=engine)

        # 创建Session:
        session = DBSession()
        return session

    @staticmethod
    def CloseSession(self,session):
        session.close()

        return
